package md5Experiments;

import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;

public class Hash {
	private Equation bits[];
	
	Hash (){
		this(0x67452301,0xefcdab89,0x98badcfe,0x10325476);
	}
	
	Hash (long a, long b, long c, long d){
		bits = new Equation[128];
		for (int i = 0; i < 32; i++) {
			bits[i] = new Equation( (513 - ((a >> i) & 1)));
		}
		for (int i = 0; i < 32; i++) {
			bits[i + 32] = new Equation(513 - ((b >> i) & 1));
		}
		for (int i = 0; i < 32; i++) {
			bits[i + 64] = new Equation(513 - ((c >> i) & 1));
		}
		for (int i = 0; i < 32; i++) {
			bits[i + 96] = new Equation(513 - ((d >> i) & 1));
		}
	}
	
	public void print() throws FileNotFoundException, UnsupportedEncodingException{
		for (int i = 0; i < 1; i++) {
			//bits[bits.length - i - 1].print();
			System.out.println(bits[bits.length - i - 1].getDepth());
		}
	}
	
	public Equation getBit(int i){
		return bits[i];
	}
	
	public void setBit(int i, Equation eq){
		bits[i] = eq;
	}
	
	public Equation[] getBits(int start, int len){
		Equation eq[] = new Equation[len];
		for (int i = start; i < start + len; i++) {
			eq[i-start] = bits[i];
		}
		return eq;
	}
	
	public void setBits(int start, int len, Equation[] word){
		for (int i = start; i < start + len; i++) {
			bits[i] = word[i-start];
		}
	}
	
	
}
